<template>
  <div class="recommend-section">
    <h2 class="section-title">
      <i class="iconfont icon-recommend"></i>
      <span>为你推荐</span>
    </h2>
    <div class="product-grid">
      <div v-for="product in products" :key="product.id" class="product-item">
        <img :src="product.imageUrl" :alt="product.name">
        <h3>{{ product.name }}</h3>
        <p class="description">{{ product.description }}</p>
        <div class="price-row">
          <span class="price">¥{{ product.price }}</span>
          <span class="original-price">¥{{ product.originalPrice }}</span>
        </div>
      </div>
    </div>
    <div class="load-more">
      <el-button @click="$emit('load-more')">加载更多</el-button>
    </div>
  </div>
</template>

<script setup>
defineProps({
  products: {
    type: Array,
    required: true
  }
})

defineEmits(['load-more'])
</script>

<style lang="scss" scoped>
.recommend-section {
  .section-title {
    display: flex;
    align-items: center;
    font-size: 20px;
    margin-bottom: 20px;

    i {
      margin-right: 8px;
      color: #ff4d4f;
    }
  }

  .product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;

    .product-item {
      background: #fff;
      border-radius: 8px;
      padding: 15px;
      transition: transform 0.3s;

      &:hover {
        transform: translateY(-5px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      }

      img {
        width: 100%;
        height: 200px;
        object-fit: cover;
        border-radius: 4px;
      }

      h3 {
        margin: 10px 0;
        font-size: 16px;
      }

      .description {
        color: #666;
        font-size: 14px;
        margin-bottom: 10px;
      }

      .price-row {
        .price {
          color: #ff4d4f;
          font-size: 18px;
          font-weight: bold;
          margin-right: 10px;
        }

        .original-price {
          color: #999;
          text-decoration: line-through;
        }
      }
    }
  }

  .load-more {
    text-align: center;
    margin-top: 30px;
  }
}
</style>
